package com.minimalist.common.entity.basic.vo.perm;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.PermEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * @author 11987
 */
@Schema(name = "权限实体")
public class PermVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @NotNull(message = "权限ID不能为空", groups = {Update.class})
    @Schema(name = "permId", description = "权限ID", type = "string")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long permId;

    @Schema(name = "permCode", description = "权限编码", type = "string")
    private String permCode;

    @NotBlank(message = "权限名称不能为空", groups = {Add.class, Update.class})
    @Schema(name = "permName", description = "权限名称", type = "string")
    private String permName;

    @NotNull(message = "上级权限ID不能为空", groups = {Add.class, Update.class})
    @Schema(name = "parentPermId", description = "父权限ID", type = "string")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentPermId;

    @NotNull(message = "排序值不能为空", groups = {Add.class, Update.class})
    @Schema(name = "permSort", description = "排序值", type = "integer")
    private Integer permSort;

    @Schema(name = "permPath", description = "路由地址", type = "string")
    private String permPath;

    @Schema(name = "permIcon", description = "权限图标，菜单可传图标", type = "string")
    private String permIcon;

    @SchemaEnum(implementation = PermEnum.PermType.class)
    @Schema(name = "permType", description = "权限类型", type = "string")
    private String permType;

    @Schema(name = "component", description = "组件路径", type = "string")
    private String component;

    @NotNull(message = "是否可见不能为空", groups = {Add.class, Update.class})
    @Schema(name = "visible", description = "是否可见", type = "boolean")
    private Boolean visible;

    @SchemaEnum(implementation = StatusEnum.class)
    @NotNull(message = "权限状态不能为空", groups = {Update.class})
    @Schema(name = "status", description = "权限状态", type = "integer")
    private Integer status;

    @Schema(name = "remark", description = "备注", type = "string")
    private String remark;

    @Schema(name = "children", description = "权限子集", type = "array")
    private List<PermVO> children;

    public Long getPermId() {
        return permId;
    }

    public void setPermId(Long permId) {
        this.permId = permId;
    }

    public String getPermCode() {
        return permCode;
    }

    public void setPermCode(String permCode) {
        this.permCode = permCode;
    }

    public String getPermName() {
        return permName;
    }

    public void setPermName(String permName) {
        this.permName = permName;
    }

    public Long getParentPermId() {
        return parentPermId;
    }

    public void setParentPermId(Long parentPermId) {
        this.parentPermId = parentPermId;
    }

    public Integer getPermSort() {
        return permSort;
    }

    public void setPermSort(Integer permSort) {
        this.permSort = permSort;
    }

    public String getPermPath() {
        return permPath;
    }

    public void setPermPath(String permPath) {
        this.permPath = permPath;
    }

    public String getPermIcon() {
        return permIcon;
    }

    public void setPermIcon(String permIcon) {
        this.permIcon = permIcon;
    }

    public String getPermType() {
        return permType;
    }

    public void setPermType(String permType) {
        this.permType = permType;
    }

    public String getComponent() {
        return component;
    }

    public void setComponent(String component) {
        this.component = component;
    }

    public Boolean getVisible() {
        return visible;
    }

    public void setVisible(Boolean visible) {
        this.visible = visible;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public List<PermVO> getChildren() {
        return children;
    }

    public void setChildren(List<PermVO> children) {
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PermVO permVO = (PermVO) o;
        return java.util.Objects.equals(permId, permVO.permId) &&
               java.util.Objects.equals(permCode, permVO.permCode) &&
               java.util.Objects.equals(permName, permVO.permName) &&
               java.util.Objects.equals(parentPermId, permVO.parentPermId) &&
               java.util.Objects.equals(permSort, permVO.permSort) &&
               java.util.Objects.equals(permPath, permVO.permPath) &&
               java.util.Objects.equals(permIcon, permVO.permIcon) &&
               java.util.Objects.equals(permType, permVO.permType) &&
               java.util.Objects.equals(component, permVO.component) &&
               java.util.Objects.equals(visible, permVO.visible) &&
               java.util.Objects.equals(status, permVO.status) &&
               java.util.Objects.equals(remark, permVO.remark) &&
               java.util.Objects.equals(children, permVO.children);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(permId, permCode, permName, parentPermId, permSort, permPath, permIcon, permType, component, visible, status, remark, children);
    }

    @Override
    public String toString() {
        return "PermVO{" +
               "permId=" + permId +
               ", permCode='" + permCode + '\'' +
               ", permName='" + permName + '\'' +
               ", parentPermId=" + parentPermId +
               ", permSort=" + permSort +
               ", permPath='" + permPath + '\'' +
               ", permIcon='" + permIcon + '\'' +
               ", permType='" + permType + '\'' +
               ", component='" + component + '\'' +
               ", visible=" + visible +
               ", status=" + status +
               ", remark='" + remark + '\'' +
               ", children=" + children +
               '}';
    }

}
